class Solution(object):
    def equalizeWater(self, buckets, loss):
        r_left = 1 - loss / 100
        left = 0
        right = max(buckets)
        e = 0.000001
        def cal(val):
            ans = 0
            for num in buckets:
                if num >= val:
                    ans += (num - val) * r_left
                else:
                    ans += num - val
            return ans >= 0

        while right - left >= e:
            mid = (right + left) / 2
            if cal(mid):
                left = mid
            else:
                right = mid
        return left